package xfyd.controller;

import com.xfyd.model.user.User;
import com.xfyd.serviece.user.impl.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 用户
 * Created by hgg on 2017-02-09.
 */
@Controller
@RequestMapping(value = "/user")
public class UserAct {

    @Resource
    private UserService userService;

    /**
     * 所有用户列表
     */
    @RequestMapping(value = "/all-list")
    public String allUsers( HttpServletRequest request ){

        List<User> users = userService.allUsers();
        if( !CollectionUtils.isEmpty( users ) ){
            request.setAttribute( "userList",users );
        }
        return "user/list";
    }
}
